package com.yu.service.impl;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yu.mapper.PatientMapper;
import com.yu.model.dto.DoctorPageDTO;
import com.yu.model.entity.Doctor;
import com.yu.mapper.DoctorMapper;
import com.yu.model.entity.Patient;
import com.yu.service.DoctorService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
* @author 33522
* @description 针对表【doctor】的数据库操作Service实现
* @createDate 2023-12-18 10:52:29
*/
@Service
public class DoctorServiceImpl extends ServiceImpl<DoctorMapper, Doctor>
    implements DoctorService {


    @Resource
    private PatientMapper patientMapper;

    @Override
    public  Page<Doctor> pageList(DoctorPageDTO doctorPageDTO) {
        Page<Doctor> doctorPage = new Page<>(doctorPageDTO.getPage(), doctorPageDTO.getPageSize());
        LambdaQueryWrapper<Doctor> doctorLambdaQueryWrapper = new LambdaQueryWrapper<>();
        doctorLambdaQueryWrapper.eq(StrUtil.isNotBlank(doctorPageDTO.getNickName()),Doctor::getNickName,doctorPageDTO.getNickName());
        page(doctorPage,doctorLambdaQueryWrapper);
        return doctorPage;
    }

    @Override
    public Patient getPatient(Long id) {
        Patient patient = patientMapper.selectById(id);

        return patient;
    }
}




